beagle<-read.table("beagle_out_8.snps_chr8.bgl.gz.r2",sep="\t")
impute<-read.table("chr8.one.phased.impute2_fil_chr8_info",sep=" ")
impute[1,]
impute<-read.table("chr8.one.phased.impute2_fil_chr8_info",sep=" ",head=T)
dim(impute)
dim(beagle)
impute[1,]
imput[1,6:7]
impute[1,6:7]
summary(impute$certainty)
summary(impute$info)
impute[1,c(2,6)]
impute<-impute[,c(2,6)]
colnames(beagle)<-c("rs_id","r2")
merged<-merge(beagle,impute,by="rs_id")
dim(merged)
merged<-merge(beagle,impute,by="rs_id",all=F)
dim(merged)
merged<-merge(beagle,impute,by="rs_id")
merged[1,]
merged[35201,]
impute<-read.table("chr8.one.phased.impute2_fil_chr8_info",sep=" ",head=T)
impute<-impute[,c(2,3,6)]
beagle[1,]
dim(beagle)
merged<-merge(beagle,impute,by="rs_id")
dim(merged)
merged[1,]
which(merged$r2 ='NaN')[1]
which(merged$r2 =='NaN')[1]
length(which(merged$r2 =='NaN'))
length(which(merged$r2 !='NaN'))
merged_f<-merged[which(merged$r2 !='NaN'),]
dim(merged_f)
merged_f[1,]
summary(merged_f$r2)
summary(merged_f$certainty)
cor(merged_f$r2,merged_f$certainty,method="pearson")
pdf("snps_dosr2_gt_0p3_beagle_vs_impute_chr8.pdf")
dev.off(0
dev.off()
pdf("beagle_r2_vs_impute_r2_chr8.pdf")
plot(merged_f$r2,merged_f$certainty,xlab = c("beagle r2"),ylab=c("impute r2"),main=main)
main<-paste("Beagle r2 VS Impute r2,pearson corr=",cor(merged_f$r2,merged_f$certainty,method="pearson"),sep=" ")
plot(merged_f$r2,merged_f$certainty,xlab = c("beagle r2"),ylab=c("impute r2"),main=main)
dev.off()
pdf("beagle_r2_vs_impute_r2_chr8.pdf")
plot(merged_f$r2,merged_f$certainty,xlab = c("beagle r2"),ylab=c("impute r2"),xlab = c("beagle r2"),ylab=c("impute r2"),main=main,pch=".")
plot(merged_f$r2,merged_f$certainty,xlab = c("beagle r2"),ylab=c("impute r2"),main=main,pch=".")
dev.off()
pdf("beagle_R2VSimpute_R2.pdf")
plot(merged_f$position,merged_f$r2,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle dosage r2 (red) vs impute dosage r2 (green)") ,pch=".",col=c("red"))
points(merged_f$position,merged_f$certainty,pch=".",col=c("green"))
dev.off()
pdf("beagle_R2VSimpute_R2.pdf")
plot(merged_f$position,merged_f$r2,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle r2 (red) vs impute r2 (green)") ,pch=".",col=c("red"))
points(merged_f$position,merged_f$certainty,pch=".",col=c("green"))
dev.off()
multhist <- function(x,main,x.loc,...) {
  new.x <- lapply(x,hist,plot=F)
  tmp <- lapply(new.x,function(x) x$breaks)
  max.break <- lapply(tmp,function(x) max(x))
  max.break <- which(unlist(max.break)==max(unlist(max.break)))[1]
  breaks <- new.x[[max.break]]$breaks
  new.x <- lapply(x,hist,plot=F,breaks=breaks)
  y.max <- max(unlist(lapply(new.x,function(x) max(x$counts))))
  barplot(do.call(rbind,lapply(new.x,function(x) x$counts)),beside=T,
          space=c(0,0),names.arg=signif(new.x[[1]]$mids,2),
          axes=T,legend.text=T,main=main,args.legend=list(x=x.loc,y=y.max),...)
}
pdf("Multiple_hist_chr8.pdf")
merged_f[1,]
multhist(x=list(Beagle_r2=[,2],Impute_r2=[,4]),main='beagle_r2VSImpute_r2')
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="beagle_r2VSImpute_r2")
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="beagle_r2VSImpute_r2", x.loc=20)
dev.off()
pdf("Multiple_hist_chr8.pdf")
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="beagle_r2VSImpute_r2", x.loc=20)
 dev.off()
savehistory("Plots.R")
pdf("Multiple_hist_chr8.pdf")
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="Beagle_r2 VS Impute_r2", x.loc=20)
 dev.off()
pdf("Multiple_hist_chr8.pdf")
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="Beagle_r2 VS Impute_r2", x.loc=50)
 dev.off()
pdf("Multiple_hist_chr8.pdf")
multhist(x=list(Beagle_r2= merged_f[,2],Impute_r2= merged_f[,4]),main="Beagle_r2 VS Impute_r2", x.loc=20)
dev.off()
savehistory("Plots.R")
